<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php $this->load->view('head'); ?>
	<script type="text/javascript">
		jQuery(document).ready(function() {
			//jQuery("input[name=startdate]").datetimepicker({timeFormat: 'hh:mm', dateFormat: 'yy-mm-dd'});
			AnyTime.picker( "startdate",
					{ earliest: new Date(), format: "%z-%m-%d %H:%i", firstDOW: 1 } );
			AnyTime.picker( "return_time",
					{ earliest: new Date(),format: "%z-%m-%d %H:%i", firstDOW: 1 } );
			jQuery("input[name=from]").geo_autocomplete({geocoder_address: true, geocoder_region: 'SG', geocoder_types: 'street_address,route,intersection,political,country,administartive_area_level_1,administartive_area_level_2,administartive_area_level_3,colloquial_area,locality,sublocality,neighborhood,premise,subpremise,postal_code,natural_feature,airport,park,point_of_intereset,post_box,street_number'});
			jQuery("input[name=to]").geo_autocomplete({geocoder_address: true, geocoder_region: 'SG', geocoder_types: 'street_address,route,intersection,political,country,administartive_area_level_1,administartive_area_level_2,administartive_area_level_3,colloquial_area,locality,sublocality,neighborhood,premise,subpremise,postal_code,natural_feature,airport,park,point_of_intereset,post_box,street_number'});
			jQuery("input[name=return]").geo_autocomplete({geocoder_address: true, geocoder_region: 'SG', geocoder_types: 'street_address,route,intersection,political,country,administartive_area_level_1,administartive_area_level_2,administartive_area_level_3,colloquial_area,locality,sublocality,neighborhood,premise,subpremise,postal_code,natural_feature,airport,park,point_of_intereset,post_box,street_number'});
			
			jQuery("input[name=returnch]").change(function () {
				if (jQuery(this).attr("checked")) {
					jQuery("input[name=return]").parent().css("display", "block");
					jQuery("input[name=return_time]").parent().parent().css("display", "block");
				} else {
					jQuery("input[name=return]").parent().css("display", "none");
					jQuery("input[name=return_time]").parent().parent().css("display", "none");
				}
			});
		});
	</script>
</head>

<body>
	<?php
	if ($user->id > 0) {
		$this->load->view('header_logged.php');
	} else {
		$this->load->view('header_guest.php');
	}
	?>
	
	<!-- Content Area -->
	<div class="wrapper-world content">
		<div class="wrapper">
			<h1>Trip Based Bus Services</h1>
			
			<div class="right-half">
				<div class="info-box">
					<div class="info-text" id="formHelper">
						For single & return trip bookings. [1-Way or 2-Way Transfer] Commonly used for ad-hoc charter. This is the most common type of Bus Chartering. The Bus is booked to do a transfer from Point A. to Point B. 2-Way Transfer often include a return from Point B. to Point A. though the return location is decided by the customer which can also represent a Point C. [ie. Kallang Way [A] to Marina Barrage [B] at 3pm, return from Marina Barrage to Cityhall MRT [C] at 6pm]. Prices are either charged at per trip rate or a 2-Way rate. Additional pick-up & drop-off locations may be added at an extra cost. Please fill in the fields on the left to get a quotation.
					</div>
				</div>
			</div>
			
			<div class="left-half">
				<?php echo form_open('request/ajaxAdd', array('class' => 'standard-form', 'id' => 'ajaxAdd')); ?>
					<div class="one">
						<label>Trip Date and Time</label>
						<div class="type-text"><input type="text" name="startdate" id="startdate" /></div>
						<div class="clr"></div>
					</div>
					<div class="one">
						<label>Number of Passengers</label>
						<div class="type-text"><input type="text" name="passangers" /></div>
						<div class="clr"></div>
					</div>
					<div class="one">
						<label>From</label>
						<div class="type-text"><input type="text" name="from" /></div>
						<div class="clr"></div>
					</div>
					<div class="one" id="locationsContainer">
						<label>To</label>
						<div class="type-text"><input type="text" name="to" /></div>
						<a href="javascript:addTripLocation('to');" class="add-remove"><img src="<?php echo site_url(); ?>assets/images/plus.png" /></a>
						<div class="clr"></div>
					</div>
					<div id="after"></div>
					<div class="one">
						<label><input type="checkbox" class="inline" name="returnch" />Return</label>
						<div class="type-text" style="display: none;"><input type="text" name="return" /></div>
						<div class="clr"></div>
					</div>
					<div class="one" style="display: none;">
						<label>Return Time</label>
						<div class="type-text"><input type="text" name="return_time" id="return_time"/></div>
						<div class="clr"></div>
					</div>
					<script type="text/javascript">
						

						// Form Help
						helpTexts['default'] = 'For single & return trip bookings. [1-Way or 2-Way Transfer] Commonly used for ad-hoc charter. This is the most common type of Bus Chartering. The Bus is booked to do a transfer from Point A. to Point B. 2-Way Transfer often include a return from Point B. to Point A. though the return location is decided by the customer which can also represent a Point C. [ie. Kallang Way [A] to Marina Barrage [B] at 3pm, return from Marina Barrage to Cityhall MRT [C] at 6pm]. Prices are either charged at per trip rate or a 2-Way rate. Additional pick-up & drop-off locations may be added at an extra cost. Please fill in the fields on the left to get a quotation.';
						helpTexts['startdate'] = 'Trip Date and Time<ul><li>Please enter your Trip Date and Time</li><li>Should your trip timing be of a tentative nature, kindly indicate in our Remarks Box beneath that the timings are to be confirmed again [TBC].</li><li>Our Peak hour timings are between [0700 - 0900, 1700 - 2000hrs]</li><li>Our Late Night Surcharge are applicable between [2230 - 0700hrs]</li></ul>';
						helpTexts['passangers'] = 'Number of Passengers<ul><li>Please indicate your number of passengers to aid us in allocating the most suitable bus type</li></ul>';
						helpTexts['from'] = 'Pick-up location<ul><li>Please enter your pick-up location</li></ul><div style="color:red;">For locations within Singapore only.</div>';
						helpTexts['to'] = 'Destinations<ul><li>Please enter the destination and press the plus button [+]</li>	<li>Should there be multiple destinations, please use the plus [+] button or you may indicate in the Remarks Box beneath.</li><li>Please note, additional charges apply for extra locations</li><li>Should there be a Return or 2-way trip, please check the Return box and enter the return location</li></ul><div style="color:red;">For locations within Singapore only.</div>';
						helpTexts['returnch'] = 'Please check if you want to add a return location';
						helpTexts['return'] = '<ul><li>Please enter return location</li></ul><div style="color:red;">For locations within Singapore only.</div>';
		
						initFormHelper('ajaxAdd', 'formHelper');
					</script>
					<input type="hidden" name="type" value="trip" />
					<input type="hidden" name="edit_id" value="" id="edit_id" />
				</form>
			</div>
			
			<div class="clr"></div>
		</div>
	</div> <!-- end of wrapper-world and .content -->
	
	<div class="wrapper-world add-btn">
		<div class="wrapper" id="addBtnCont">
			<a href="javascript:addJobTrip();" title="Add this job order">ADD</a>
			<div class="add-info">If you have completed your addition, please click <strong>next</strong> located at the bottom of the page.</div>
			<div class="clr"></div>
		</div>
		
		<div class="wrapper" id="editBtnCont" style="display:none;">
			<a href="javascript:addJobTrip();" title="Edit this job order" class="apply-btn">APPLY</a> <a href="javascript:cancelEdit();" title="Add this job order" class="cancel-btn">CANCEL</a>
			<div class="clr"></div>
		</div>
	</div>
	
	<div class="job-listing">
		<?php $c = 0; foreach ($jobs as $job): ?>
		<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); ?>" id="job_<?php echo $job->id; ?>">
			<div class="wrapper">
				<?php if ($job->job_type == 1): ?>
				<div class="job-type time-based">Time Based</div>
				<?php elseif ($job->job_type == 0): ?>
				<div class="job-type trip-based">Trip Based</div>
				<?php endif; ?>
				<div class="job-details"><?php echo nl2br($this->Jobs->formatJobInfo($job)); ?></div>
				<div class="job-edit"><a href="javascript:editJobTrip(<?php echo $job->id; ?>);" title="Edit job order">Edit</a></div>
				<div class="job-delete"><a href="javascript:deleteJob(<?php echo $job->id; ?>);" title="Delete job order">Delete</a></div>
				<div class="clr"></div>
			</div>
			<?php
				if ($job->job_type == 0) {
					$job->from = htmlspecialchars($job->from, ENT_QUOTES);
					$aLocs = json_decode($job->to);
					for ($ji = 0; $ji < count($aLocs); $ji++)
						$aLocs[$ji] = htmlspecialchars($aLocs[$ji], ENT_QUOTES);
					$job->to = json_encode($aLocs);
				} elseif ($job->job_type == 1) {
					$aLocs = json_decode($job->locations);
					for ($ji = 0; $ji < count($aLocs); $ji++)
						$aLocs[$ji] = htmlspecialchars($aLocs[$ji], ENT_QUOTES);
					$job->locations = json_encode($aLocs);
				}
			?>
			<input type="hidden" class="job_json" value='<?php echo json_encode($job); ?>' />
		</div>
		<?php $c++; endforeach; ?>
		
		<!-- <div class="wrapper-world job-even">
			<div class="wrapper">
				<div class="job-type trip-based">Time Based</div>
				<div class="job-details">Job info.....</div>
				<div class="job-edit"><a href="" title="Edit job order">Edit</a></div>
				<div class="job-delete"><a href="" title="Delete job order">Delete</a></div>
				<div class="clr"></div>
			</div>
		</div> -->
	</div>
	
	<div class="wrapper">
		<div class="conv-left">
			<div class="avatar"></div>
			<div class="mid"><div class="top"><div class="bot">
			<?php echo form_open('request/jobOrder', array('class' => 'left-aligned', 'id' => 'jobOrder')); ?>
				<input type="hidden" name="draft" value="0" />
				<input type="hidden" name="type" value="trip" />
				<input type="hidden" name="orderId" id="orderId" value="<?php echo $orderId; ?>" />
				<div class="one">
					<label>I would like to supply the following information:</label>
					<div class="type-textarea"><textarea name="moreinfo" id="moreinfo"></textarea></div>
					<div class="clr"></div>
				</div>
			</form>
			<script type="text/javascript">
				helpTexts['moreinfo'] = 'Please include any additional information / instructions here';
				
				jQuery("#moreinfo").val(helpTexts['moreinfo']);
				
				jQuery("#moreinfo").focus(function() {
					if (jQuery(this).val() == helpTexts['moreinfo']) {
						jQuery(this).val("");
					}
				});
				
				jQuery("#moreinfo").blur(function() {
					if (jQuery(this).val() == "") {
						jQuery(this).val(helpTexts['moreinfo']);
					}
				});
			</script>
			</div></div></div>
			<div class="clr"></div>
		</div>
	</div>
	
	<div class="wrapper">
		<div class="action-buttons">
			<?php
			if ($user->level > 0) {
				if ($orderId > 0) {
					$sendText = 'Transform';
				} else {
					$sendText = 'Add Order';
				}
			}
			?>
			<?php if (!($orderId > 0) && $user->level < 1): ?><a class="more" href="javascript:jobOrder(1);"><span>Save as draft</span></a> <?php endif; ?><a class="more" href="javascript:jobOrder();"><span><?php echo $sendText; ?></span></a>
		</div>
	</div>
	
	<div class="wrapper-world footer-top">
		<div class="wrapper"></div>	
	</div>
	
	<?php if ($editId > 0): ?>
	<script type="text/javascript">
		jQuery(document).ready(function() { editJobTrip(<?php echo $editId; ?>); });
	</script>
	<?php endif; ?>
	
	<?php $this->load->view('footer'); ?>
</body>
</html>
